package com.mzj.saas.rent;

import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.core.BaseController;
import com.haixiaoke.saas.repository.pojo.HouseInspectionFacility;
import com.haixiaoke.saas.repository.service.IHouseInspectionFacilityService;
import com.mzj.saas.annotation.CheckAuth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 验房设施Controller
 *
 * @author xiaolong
 * @date 2023-04-17
 */
@RestController
@RequestMapping("/house/inspectionFacility")
public class HouseInspectionFacilityController extends BaseController {
    @Autowired
    private IHouseInspectionFacilityService houseInspectionFacilityService;

    /**
     * 查询验房设施列表
     */
    @GetMapping("/list")
    @CheckAuth
    public AjaxResult list(HouseInspectionFacility houseInspectionFacility) {
        List<HouseInspectionFacility> list = houseInspectionFacilityService.selectHouseInspectionFacilityList(houseInspectionFacility);
        return success(list);
    }

    /**
     * 获取验房设施详细信息
     */
    @GetMapping(value = "/{facilitiesInspectionId}")
    public AjaxResult getInfo(@PathVariable("facilitiesInspectionId") Long facilitiesInspectionId) {
        return success(houseInspectionFacilityService.selectHouseInspectionFacilityByFacilitiesInspectionId(facilitiesInspectionId));
    }

    /**
     * 新增验房设施
     */
    @PostMapping
    public AjaxResult add(@RequestBody HouseInspectionFacility houseInspectionFacility) {
        return toAjax(houseInspectionFacilityService.insertHouseInspectionFacility(houseInspectionFacility));
    }

    /**
     * 验房设施
     */
    @PutMapping
    @CheckAuth
    public AjaxResult edit(@RequestBody HouseInspectionFacility houseInspectionFacility) {
        return toAjax(houseInspectionFacilityService.updateHouseInspectionFacility(houseInspectionFacility));
    }

    /**
     * 删除验房设施
     */
    @DeleteMapping("/{facilitiesInspectionIds}")
    public AjaxResult remove(@PathVariable Long[] facilitiesInspectionIds) {
        return toAjax(houseInspectionFacilityService.deleteHouseInspectionFacilityByFacilitiesInspectionIds(facilitiesInspectionIds));
    }
}
